<template>
	<view class="container">
		<view @click="toDetail(item.id,item.name,item.description)" class="item" v-for="(item, index) in list"
			:key="item.id">
			<!-- 
			<image src="https://zlw-blog.oss-cn-hangzhou.aliyuncs.com/2024/08/13/subject_bg.png" mode="widthFix"
				class="cover"></image> -->
			<image src="../../static/img/zlwblog.png" class="cover">
			</image>
			<view class="info">
				<view class="title">{{item.name}}</view>
				<view class="summary">{{item.description}}</view>
			</view>

		</view>
		<u-loading-page :loading="loading" loading-text="loading..."></u-loading-page>
	</view>
</template>

<script>
	import {
		getCategoryList
	} from '../../api/category'

	export default {
		data() {
			return {
				list: [],
				loading: false
			}
		},
		methods: {
			getList() {
				this.loading = true
				getCategoryList().then(res => {
					this.list = res
					this.loading = false
				}).catch(() => {
					this.loading = false
				})
			},
			toDetail(id, name, description) {
				uni.navigateTo({
					url: `/pages/article/index?id=${id}&name=${name}&description=${description}`
				})
			}
		},
		onLoad() {
			this.getList()
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		background-color: #FFF;
	}

	.item {
		margin: 30rpx 30rpx 0;
		min-height: 200rpx;
		border-radius: 10rpx;
		box-shadow: 0 6rpx 4rpx 2rpx #F2F2F2;

		&:last-child {
			margin-bottom: 30rpx;
		}

		.cover {
			width: 100%;
			border-radius: 10rpx;
		}

		.info {
			padding: 0 20rpx 20rpx;

			.title {
				font-size: 28rpx;
				font-weight: bold;
				margin: 10rpx 0 6rpx;
			}

			.summary {
				color: #777;
				font-size: 24rpx;
			}
		}
	}
</style>